<template>
	<view class="main">
		<navbar title="服务站点" transparent></navbar>
		<!-- <view class="map">
			<image src="@/static/map.jpg" mode="widthFix"></image>
		</view> -->
	<!-- 	<view class="content">
			<view class="item" v-for="item in dataList" :key="item.id" @click="toDetail(item)">
				<view class="item-label">
					{{item.title}}
				</view>
				<view class="item-icon">
					<image src="@/static/moreIcon.png" mode=""></image>
				</view>
			</view>
		</view> -->
		
		<view class="content" :style="{paddingTop:(getStateHeight + getNavbar  ) + 'px'}">
			<view class="item-box">
				<view class="item" v-for="item in dataList" :key="item.id" @click="toDetail(item)">
					<view class="item-icon">
						<image :src="baseImage + item.picdir" mode="" v-if="item.picdir"></image>
						<image src="@/static/gonIcon1.png" mode="" v-else></image>
					</view>
					<view class="item-label">
						{{ item.title}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapGetters,
		mapState,
	} from 'vuex';
	import Navbar from '@/components/Navbar.vue'
		import {getServeList} from "@/core/web-api/qiuzhiduan.js"
	export default{
		data(){
			return {
				dataList:[],
				page:{
					current:1,
					limit:10,
				}
			}
		},
		methods:{
			toDetail(item){
				uni.navigateTo({
					url:"/pages/web/service/share/siteList?id=" + item.id
				})
			},
			/**
			 * 加载数据
			 */
			getList() {
				getServeList({
					...this.page,
					cataName:"站点导航"
				}).then(res => {
					if (res.code == 20000) {
						const {
							total,
							list
						} = res.data;
						if (this.page.current == 1) {
							this.dataList = list;
						} else {
							this.dataList.push(...list);
						}
						this.total = total;
					}
				})
			},
			
			/**
			 * 分页加载
			 */
			pageData() {
				if (this.total == this.dataList.length) return;
				this.page.current++;
				this.getList()
			},
		},
		onReachBottom() {
			this.pageData();
		},
		components:{
			Navbar
		},
		computed: {
			...mapGetters(['getNavbar', 'getStateHeight', 'getSafeBottom']),
			...mapState(['baseImage'])
		},
		created() {
			this.getList()
		}
	}
</script>

<style scoped lang="less">
	.main {
		width: 100%;
		box-sizing: border-box;
	
	}
	.map{
		width: 100%;
		image{
			width: 100%;
			font-size: 0;
		}
	}
	.content{
		margin-top: 30upx;
		display: flex;
		flex-flow: wrap;
		justify-content: center;
	}
	.item{
		width: 216upx;
		height: 216upx;
		background-color: #fff;
		border-radius: 20upx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-left: 20upx;
		margin-bottom: 20upx;
		box-shadow: 12upx 0 28upx rgba(202,206,216,.35);
		&-box{
			width: 710upx;
			margin-left: -20upx;
			display: flex;
			flex-flow: wrap;
		}
		&-icon{
			width: 45upx;
			height: 45upx;
			image{
				width: 45upx;
				height: 45upx;
			}
		}
		&-label{
			width: 120upx;
			margin-top: 25upx;
			font-size: 26upx;
			color: #4d4d4d;
		}
	}
</style>